<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>忘记密码</title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/main.css" />
		<link href="../css/mui.picker.css" rel="stylesheet" />
		<link href="../css/mui.poppicker.css" rel="stylesheet" />
		<style>
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			
			.mui-input-group label {
				width: 22%;
			}
			
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
				height: 0.9rem;
				font-size: 14px;
			}
			
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			
			.mui-content-padded {
				margin-top: 25px;
			}
			
			#reg {
				padding: 10px;
				border-radius: 15px;
				width: 80%;
				margin: 0 auto;
			}
			
			#reg span {
				font-size: 12px;
			}
			
			.mui-input-group {
				background: none;
			}
			
			.mui-input-group:before,
			.mui-input-group:after {
				height: 0;
			}
			
			.mui-input-group input {
				background-color: #FFFFFF;
				width: 87%;
				border-radius: 25px;
				margin: 15px;
			}
			
			.mui-input-group .mui-input-row:after {
				height: 0;
			}
			
			.mui-input-group .mui-input-row {
				text-align: center;
			}
			
			.mui-input-group .mui-input-row {
				height: inherit;
			}
			
			p {
				font-size: 14px;
				margin-top: 20px;
				margin-bottom: 10px;
				color: #8f8f94;
			}
			
			p a {
				color: #000000;
				padding: 0 20px;
			}
			
			.mui-content {
				background: none;
			}
			
			#showUserPicker {
				float: inherit;
				width: 87%;
				padding: 10px 15px;
			}
			
			.mui-input-group label {
				position: absolute;
				top: 5px;
				left: -5px;
			}
			
			.mui-input-group img {
				width: 0.4rem;
				vertical-align: -webkit-baseline-middle;
				padding-top: 10px;
			}
			
			.mui-input-group input {
				background-color: #FFFFFF !important;
				width: 95% !important;
				border-radius: 25px !important;
				margin: 10px 0px 10px 0px!important;
				margin-top: 10px;
				padding-left: 55px !important;
				float: inherit !important;
			}
			
			#reg {
				padding: 10px;
				border-radius: 20px;
				width: 100%;
				margin: 0 auto;
				background-color: #718fbd;
				border: 1px solid #718fbd;
			}
			
			.guo_num {
				position: relative;
			}
			
			.guo_numa {
				position: absolute;
				top: 25%;
				left: 65%;
				border-radius: 20px;
			}
			
			.yanzhengBtn {
				position: absolute;
				top: 20px;
				right: 35px;
				background: #a7bad6;
				border: 0;
				border-radius: 20px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">忘记密码</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">

				<div class="mui-input-row">
					<label><img src="../images/exit/sj.png" /></label>
					<input id='phoneNo' name='phoneNo' type="number" class="mui-input phoneNumber" placeholder="请输入手机号"></input>
				</div>
				<div class="mui-input-row guo_num">
					<label><img src="../images/exit/yzm.png" /></label>
					<input id='checkcode' name='' type="number" class="mui-input yanzhengma" placeholder="请输入验证码"><button type="button" class="guo_numa" id="yanzhengBtn" style="background-color:#a7bad6;color:#ffffff">获取验证码</button> </input>
				</div>
				<!--<div class="mui-input-row">
					<label><img src="../images/exit/mm.png" /></label>
					<input id='doublepassword' name='doublepassword' type="password" class="mui-input password" placeholder="请输入确认密码"></input>
				</div>-->
			</form>
			<div class="mui-content-padded">
				<button id='reg' class="mui-btn mui-btn-block mui-btn-primary "><span>保存</span></button>
			</div>

		</div>
		
	

	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/app.js"></script>
	<script type="text/javascript" src="../js/constants.js"></script>
	<script type="text/javascript" src="../js/sharemethods.js"></script>
	<script type="text/javascript" src="../js/xiangyingshi.js"></script>
	<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
		<script>






			(function($, doc) {
				$.init();
				$.plusReady(function() {
					

					//倒计时
					var past_time = 0,
						begin_time = localStorage.getItem("begin_time"),
						daojishi_current = localStorage.getItem("miao");
					var daojishi2 = 60;
					console.log(daojishi_current != null && begin_time != null);
					if(daojishi_current != null && begin_time != null) {
						//获取存在本地的退出时间
						daojishi_current = localStorage.getItem("miao");
						console.log("lorg" + daojishi_current);
						//获取最开始时间
						begin_time = localStorage.getItem("begin_time");
						console.log("current" + begin_time);
						console.log(date_Time_minus(begin_time, daojishi_current));
						past_time = date_Time_minus(begin_time, daojishi_current).split(":")[0] * 60 + parseInt(date_Time_minus(begin_time, daojishi_current).split(":")[1]);
						console.log(past_time);
						daojishi2 = 60 - past_time;
						var daojishi_interval = setInterval(function() {
							if(daojishi2 > 0) {
								document.querySelector('#yanzhengBtn').innerHTML = daojishi2 + "秒";
								document.querySelector('#yanzhengBtn').setAttribute("class", "verification size12 mui-disabled");
								daojishi2--;
								//								console.log(date_All_format());
								localStorage.setItem("miao", date_All_format());
							} else {
								document.querySelector('#yanzhengBtn').innerHTML = "获取验证码";
								document.querySelector('#yanzhengBtn').setAttribute("class", "verification size12");
								document.querySelector("#save").setAttribute("class", "mui-btn mui-btn-block mui-btn-primary");
								clearInterval(daojishi_interval);
								localStorage.clear();
								daojishi2 = 60;
								past_time = 0;
							}
						}, 1000);
					}
					//发送请求按钮的点击事件
					document.getElementById("yanzhengBtn").addEventListener('tap', function() {
						// 关闭软键盘
						document.activeElement.blur();
						var phone = document.getElementById("account").value;
						var phone_validate = /1[3|5|7|8|]\d{9}/; //验证手机号码是否正确
						time_current = date_All_format();
						console.log("current" + time_current);
						localStorage.setItem("begin_time", date_All_format());
						if(phone == "") {
							mui.toast('请填写手机号')
							return false;
						}
						if(phone.length != 11) {
							mui.toast('手机号码位数不正确');
							return false;
						}
						if(!phone_validate.test(phone)) {
							mui.toast('手机号码错误');
							return false;
						}

						document.querySelector('#yanzhengBtn').setAttribute("class", "verification size12 mui-disabled");

						var url = serverAddress + "/api/patient/appsendBackVerCode";
						console.log(url);

						
						var yanzhengInfo = {
							pn: document.getElementById("account").value,
							uid: plus.push.getClientInfo().clientid
						};
						var sussess = function(data) {
							//服务器返回响应，根据响应结果，分析是否登录成功；
								console.log(JSON.stringify(data));
								if(data.result == "sendfailed") {
									mui.toast("发送失败");
									document.querySelector('#yanzhengBtn').setAttribute("class", "verification size12");
									return false;
								}
								if(data.result == "non-existent") {
									mui.toast("该手机号不存在");
									return false;
								}
								if(data.result == "success") {
									mui.toast("验证码发送成功");
									var daojishi_interval = setInterval(function() {
										if(daojishi2 > 0) {
											document.querySelector('#yanzhengBtn').innerHTML = daojishi2 + "秒";
											document.querySelector('#yanzhengBtn').setAttribute("class", "verification size12 mui-disabled");
											daojishi2--;
											//								console.log(date_All_format());
											localStorage.setItem("miao", date_All_format());

										} else {
											document.querySelector('#yanzhengBtn').innerHTML = "获取验证码";
											document.querySelector('#yanzhengBtn').setAttribute("class", "verification size12");
											document.querySelector("#save").setAttribute("class", "mui-btn mui-btn-block mui-btn-primary");
											localStorage.clear();
											clearInterval(daojishi_interval);
											past_time = 0;
											daojishi2 = 60;
										}
									}, 1000);

								}
						};
						commonHttpUtils(url, "get", yanzhengInfo, sussess, error,true);
					});
					document.getElementById("reg").addEventListener("tap", function(e) {
//						var account = document.getElementById("account").value;
//						var password = document.getElementById("password").value;
						var url = serverAddress + "/api/patient/appgetbackpassword";
						console.log("reg"+url);

						var xiugaiInfo={
							account: account,
							Validation_password: password
						};
						var sussess = function(data) {
							//服务器返回响应，根据响应结果，分析是否登录成功；
							console.log(JSON.stringify(data));
							if(data.result == "verCodeKey is wrong") {
								mui.toast("验证码错误");
								return false;
							}
							if(data.result == "non-existent") {
								mui.toast("该手机号不存在");
								return false;
							}
							if(data.result == "success") {
								mui.openWindow({
									id: 'set_newpws.html',
									url: 'set_newpws.html',
									show: {
										autoShow: false, //页面loaded事件发生后自动显示，默认为true
										event: 'loaded' //页面显示时机，默认为titleUpdate事件时显示
									},
									waiting: {
										autoShow: true //自动显示等待框，默认为true
									}
								});
								var geren_message = plus.webview.getWebviewById('set_newpws.html');
								geren_message.addEventListener('loaded', function() {
									mui.fire(geren_message, "acount", {
										acount: account,
									});
								});
							}
						};
						commonHttpUtils(url, "post",xiugaiInfo, sussess, error,true);
					})

				});
			}(mui, document));
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
//			........................................
//			mui.init();
//			var hospital = '';
//			var hospitalText = '';
//			mui.plusReady(function() {
//				if(plus.navigator.isImmersedStatusbar()) { // 兼容immersed状态栏模式
//					// 获取状态栏高度并根据业务需求处理，这里重新计算了子窗口的偏移位置
//					topoffset = (Math.round(plus.navigator.getStatusbarHeight()) + 45) + 'px';
//					document.querySelector("header").style.height = topoffset;
//					document.querySelector("header").style.paddingTop = "20px";
//					document.querySelector(".mui-bar-nav~.mui-content").style.paddingTop = topoffset;
//				}
//				// 加载完毕后关闭等待框，并展示页面
//				var currentView = plus.webview.currentWebview();
//				currentView.show('slide-in-right', 200);
//				plus.nativeUI.closeWaiting();






//
//				document.getElementById("yanzhengBtn").addEventListener('tap', function() {
//					mui.toast("验证码已发送");
//				});
//				
			
				document.getElementById("reg").addeventlistener('tap',function(){
					var phoneNo=$('#phoneNo').val()
					var checkcode=$('#checkcode').val()
					
					var data = {
						checkCode: checkcode,
						cardUserPhone: phoneNo
					};
				
					var sussess = function(data) {
						//服务器返回响应，根据响应结果，分析是否登录成功；
						if(data.result == "success") {
							localStorage.clear();
							plus.runtime.restart();
							
						} else {
							mui.toast("验证码错误,请重新输入");
						}
					};
					commonHttpUtils(chengephonenoUrl, "put", data, sussess, error);
				});
			});
			
			
		</script>
		</body>
		</html>